//
//  Sr2DetailViewController.swift
//  edu
//
//  Created by karlzhou on 15/12/3.
//  Copyright © 2015年 karlzhou. All rights reserved.
//

import UIKit
import NKJPagerViewController
class Sr2DetailViewController: NKJPagerViewController,NKJPagerViewDataSource,NKJPagerViewDelegate {
    var viewControllers : [UIViewController]=[]
    var titles:[String] = []
//    convenience init(vcs : [UIViewController],titles:[String]){
//        self.init()
//        self.viewControllers = vcs;
//        self.titles=titles
//    }
//    init(){
//        super.init(coder: <#T##NSCoder#>)!
//      //super.init()
//    }
//    
//
//    required init?(coder aDecoder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }
    override func viewDidLoad() {
        super.viewDidLoad()
        print("init the view")
        self.delegate! = self
        
        self.dataSource! = self
        
        // Do any additional setup after loading the view.
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    
    //Tab数量：
    func numberOfTabView() -> UInt
    {
        return UInt( self.titles.count)
    }
    //Tab宽度：
    func widthOfTabView() -> Int
    {
        return Int(self.view.bounds.size.width)/self.titles.count;
    }
    //设置各个页面里面的VC:
    func viewPager(viewPager: NKJPagerViewController!, contentViewControllerForTabAtIndex index: UInt) -> UIViewController! {
        let vc = UIViewController()
        vc.title = "title\(index)"
        return vc
       //return self.viewControllers[Int(index)]
    }
    //设置Tab里面的视图：
    func viewPager(viewPager: NKJPagerViewController!, viewForTabAtIndex index: UInt) -> UIView! {
        let tab = UILabel(frame: CGRectMake(0, 0, self.view.bounds.size.width/CGFloat(self.titles.count), 44))
        tab.text = "content:\(index)"
        tab.textAlignment = .Center
        tab.sizeToFit()
        return tab
    }
    
    //
    //    可选的delegate方法：
    //    - (void)viewPager:(NKJPagerViewController *)viewPager didSwitchAtIndex:(NSInteger)index withTabs:(NSArray *)tabs
    
    
}
